﻿@using Model;
@using Common;
@{
    ViewBag.Title = "博客列表";
    ViewBag.BlogCss= "active";
    ReturnMessages_Page rm = ViewBag.mess;
    List<Blog> list = (List<Blog>)rm.rows;
    Member admin = ViewBag.admin;
}

<ul class="breadcrumb">
    <li>博客管理<span class="divider">/</span></li>
    <li class="active">@ViewBag.Title</li>
</ul>
<div class="container-fluid">
    <div class="row-fluid">

        <div class="row-fluid">

            <div class="btn-toolbar">
                <a class="btn" href="/Admin/Blog/Add"><i class="fa fa-plus"></i> 新增</a>
                <a class="btn" href="javascript:void(0);" onclick="careateall();"><i class="fa fa-file-text"></i> 重新生成所有</a>
                
                <div class="btn-group pull-right">
                        <form class="form-inline" method="get" action="/Admin/Blog/List">
                            <input type="text" class="form-control" name="title_search" id="title_search" placeholder="标题" value="@ViewBag.title_search">
                            <button type="submit" class="btn"><i class="fa fa-search"></i> 查询</button>
                        </form>
                </div>
                
            </div>
            <div class="well">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th style="width:60px;">编号</th>
                            <th style="width:200px;">标题</th>
                            <th style="width:100px;">时间</th>
                            <th style="width:190px;">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in list)
                        {
                            <tr>
                                <td>@item.blog_id</td>
                                <td>
                                @if (item.blog_type == 0)
                                {
                                    <span style="font-size:11px;color:#FF0000;"> (草稿)</span>
                                    <a target="_blank" href="/Blog/Model/@item.blog_id">@item.blog_title</a>
                                }
                                else
                                {
                                    <a target="_blank" href="/html/@(item.blog_id).html ">@item.blog_title</a>
                                }
                                    
                                </td>
                                <td>@item.blog_addtime</td>
                                <td>
                                    <a class="btn btn-info" href="/Admin/Blog/Edit/@item.blog_id"><i class="fa fa-edit"></i> 编辑</a>
                                    <a class="btn btn-danger" onclick="del('@item.blog_id')"><i class="fa fa-trash-o"></i> 删除</a>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            @Html.Raw(MyHtmlHelper.ShowPageNavigate(ViewBag.request_url,rm.pageindex, ViewBag.pageCount, rm.total, (string)ViewBag.search_url))

        </div>



        @Html.Partial("_footer")

    </div>
</div>
<script>
    function del(id)
    {
        ConfirmDialog('确定要删除这条数据？', function () {
            AjaxGet('/Admin/Blog/Delete', { 'id': id }, function (mess) {
                AlertDialog(mess.msg, function () {
                    if (mess.code==200) {
                        location.href = "/Admin/Blog/List";
                    }
                });
            });
        });
    }

    function careateall()
    {
        ConfirmDialog('确定要重新生成所有数据吗？', function () {
            AjaxGet('/Admin/Blog/CreateAll',null, function (mess) {
                AlertDialog(mess.msg);
            });
        });

    }
</script>